from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'host_manager.settings')

app = Celery('host_manager')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

# 配置 Celery 定时任务
from celery.schedules import crontab

CELERY_BEAT_SCHEDULE = {
    'update-host-statistics': {
        'task': 'hosts.tasks.update_host_statistics',
        'schedule': crontab(minute=0, hour=0),  # 每天 00:00 执行
    },
}